#ifndef MAINPAGEWIDGET_H
#define MAINPAGEWIDGET_H

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QStackedWidget>

#include "NavigationWidget.h"
#include "SmeltingConfigWidget.h"
#include "MainOperationWidget.h"

class MainPageWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MainPageWidget(QWidget *parent = nullptr);
    ~MainPageWidget();
    
    // 获取导航栏组件的公共接口
    NavigationWidget* getNavigationWidget() const;
    MainOperationWidget* getMainOperationWidget() const;
    WId getVideoWindowHandle() const;

protected:
    void paintEvent(QPaintEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

signals:
    void logoutRequested();
    void moduleSelected(const QString &moduleName);
    void navigationSelectedByIndex(int stoveIndex, int pageIndex);

private slots:
    void onNavigationItemClickedByIndex(int stoveIndex, int pageIndex);
    void onstoveExpanded(const QString &stoveName);
    void onToggleNavigationButtonClicked();

private:
    void setupUI();
    void setupConnections();
    void setupContentArea();
    void setupNavigationContainer();
    void updateNavigationContainerGeometry();
    
    // 布局组件
    QHBoxLayout *m_mainLayout;
    
    // 导航栏组件
    NavigationWidget *m_navigationWidget;
    
    // 导航栏控制按钮
    QPushButton *m_toggleNavigationButton;
    bool m_navigationVisible;
    
    // 导航栏容器（悬浮在内容区域上）
    QWidget *m_navigationContainer;
    
    // 内容区域
    QStackedWidget *m_stackWidget;
    SmeltingConfigWidget *m_smeltingConfigWidget;
    MainOperationWidget *m_mainOperationWidget;
    
    // 背景
    QPixmap m_backgroundPixmap;
};

#endif // MAINPAGEWIDGET_H
